$(function() {

// ------------------------------------------------------------------------------------------------------------------
// ----------------------------列表页面------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------------------

	//获取所在城市的数据
    $.get(jumpUrl+'/lawyer/workscopes', function(data){
          
        }, "json").error(function(data) {
          var status_code = $.parseJSON(data.responseText);
          layer.msg(status_code.message);
        }).success(function(data) {
           var obj = data.data;
            var work_scope = obj;
            var src = '';
            $.each(work_scope, function(key, item) {
            	src+='<a href="javascript:void(0);" value="'+item.key+'">'+item.value+'</a>';
            });
            $(".type-box1").append(src);
    });
    //获取擅长领域的数据
    $.get(jumpUrl+'/lawyer/workscopes', function(data){
          
        }, "json").error(function(data) {
          var status_code = $.parseJSON(data.responseText);
          layer.msg(status_code.message);
        }).success(function(data) {
           var obj = data.data;
            var work_scope = obj;
            var src = '';
            $.each(work_scope, function(key, item) {
              src+='<a href="javascript:void(0);" value="'+item.key+'">'+item.value+'</a>';
            });
            $(".type-box2").append(src);
    });

    //获取执业年限的数据
    $.get(jumpUrl+'/lawyer/practiseperiods ', function(data){
          
        }, "json").error(function(data) {
          var status_code = $.parseJSON(data.responseText);
          layer.msg(status_code.message);
        }).success(function(data) {
           var obj = data.data;
            var work_scope = obj;
            var src = '';
            $.each(work_scope, function(key, item) {
              src+='<a href="javascript:void(0);" value="'+item.key+'">'+item.value+'</a>';
            });
            $(".type-box3").append(src);
    });



    $(".search-input").focus(function(){  // 获得焦点
    		$(".search-input").css({"border":"1px solid #48b4ff"});
    		$(".search-icon").css("background","url("+jumpUrl+"/img/question2/searchs.png)");
        // 定时自动搜索
        var searchval = "";
        setInterval(function(){
          cu_params = $(".search-input").val();
          if (cu_params!==""&cu_params!==searchval) {
            initialization();
            geturl();
            searchval = $(".search-input").val();
          }
          
        },2000);
    		// $(".fuzzy-search").css({"display":"block","border-top":"none"});
    	}).blur(function(){     // 失去焦点
    		$(".search-input").css({"border":"1px solid #e8e8e8"});
    		$(".search-icon").css("background","url("+jumpUrl+"/img/question2/search.png)");
		// $(".fuzzy-search").css({"display":"none"});
	});

  // 请求列表
  function get_question_list(question_list_url){
    var loading = '<div class="loading">加载中...</div>';
    $(".question-list-box2").append(loading);
    $.get(question_list_url,function(data){
      },'json').error(function(data){
        var obj = $.parseJSON(data.responseText);
        layer.msg(obj.error_messages);
      }).success(function(data){
        $(".loading").remove();
        var obj = data.data;
        var length = obj.length;
        console.info(obj);
        var src = '';
        if (obj.length>7) {
                $(".load-more").css("display","block")
              }else{
                $(".load-more").css("display","none")
              }
        if (obj.length>0) {
          for(var i = 0;i < obj.length; i++){
            src +='<li>'
              src +='<div class="fl"><img src="'+jumpUrl+'/img/dfimg.png" width="80" height="80"></div>'
              src +='<div class="fl font16 lv-info-box">'
               src +=' <p class="font20 lv-name">张三</p>'
                src +='<p class="colorF address">广东省-深圳市</p>'
                src +='<p class="colorF">广东瑞霆律师事务所     10年执业经验 </p>'
               src +=' <p class="law-type"><span>公司法务</span> <span>婚姻家庭</span> <span>劳动纠纷</span></p>'
              src +='</div>'
              src +='<div class="fl textac font14">'
                src +='<p class="colorC">20</p>'
                src +='<p class="colorD">接单数</p>'
                src +='<br>'
                src +='<p class="colorC">20</p>'
                src +='<p class="colorD">评分</p>'
              src +='</div>'
              src +='<div class="fr">'
                src +='<div class="colorD"><span class="colorC">199</span>元/次</div>'
                src +='<div class="butC" style="margin-top:85px;">选Ta为我服务</div>'
              src +='</div>'
            src +='</li>'
          }
          $(".question-list-box2").append(src);
        }else{
        var str ='<li class="textac"><span class="colorB">暂无数据</span></li>';
        $(".question-list-box2").append(str);
      }
      });
  }

// 初始化
  function initialization(){
    $(".question-list-box2 li").remove();
    $(".load-more").attr("data-id",1);
  }
  // 请求的url
  geturl();
  function geturl(){
   var post_category = $(".type-box a.cuB").attr("value");
   var params = $(".search-input").val();
   var index = $(".load-more").attr("data-id");
   var oeder_params = $(".type-nav2 .cuB").attr("data-id");
   if (post_category == undefined) {post_category=""};
   if (oeder_params == undefined) {oeder_params=""};
   if (index == "1") {index = ""};
   var question_list_url= jumpUrl+"/lawyer/list_lawyers?page="+index;
    // var question_list_url= apitest+"/question?type=question&post_category="+post_category+"&order="+oeder_params+"&q="+params+"&size=8&page="+index;
    console.info(question_list_url)
    get_question_list(question_list_url);
  }
    // 所在城市搜索
    $(document).on("click",".type-box1 a",function(){
      var type_box = $(this).attr("class");
      if (type_box !== "cuB") {
        $(".type-box1 a").removeClass("cuB");
        $(this).addClass("cuB");
      }else{
        $(".type-box1 a").removeClass("cuB");
      }
      initialization();
      geturl();
    });
    // 擅长领域搜索
    $(document).on("click",".type-box2 a",function(){
      var type_box = $(this).attr("class");
      if (type_box !== "cuB") {
        $(".type-box2 a").removeClass("cuB");
        $(this).addClass("cuB");
      }else{
        $(".type-box2 a").removeClass("cuB");
      }
      initialization();
      geturl();
    });
    // 执业年限搜索
    $(document).on("click",".type-box3 a",function(){
      var type_box = $(this).attr("class");
      if (type_box !== "cuB") {
        $(".type-box3 a").removeClass("cuB");
        $(this).addClass("cuB");
      }else{
        $(".type-box3 a").removeClass("cuB");
      }
      initialization();
      geturl();
    });
    // 执业年限搜索
    $(document).on("click",".type-box3 a",function(){
      var type_box = $(this).attr("class");
      if (type_box !== "cuB") {
        $(".type-box3 a").removeClass("cuB");
        $(this).addClass("cuB");
      }else{
        $(".type-box3 a").removeClass("cuB");
      }
      initialization();
      geturl();
    });
    // 执业年限搜索
    $(document).on("click",".typeMax",function(){
      var type_box = $(this).attr("data-href");
      if (type_box !== "cuB") {
        $(".typeMax").removeClass("cuB");
        $(this).addClass("cuB");
        $(this).attr("data-href","cuB");
      }else{
        $(".typeMax").removeClass("cuB");
        $(".typeMax").attr("data-href","");
      }
      initialization();
      geturl();
    });

     // 加载更多
    $(document).on("click",".load-more",function(e){
      index = parseInt($(".load-more").attr("data-id"))+1;
      $(".load-more").attr("data-id",index);
      geturl();
    });

    // 点击搜索图标
    $(".search-icon").click(function(){
      initialization();
      geturl();
    });

  // 点击搜索
  $(document).on("click","#subSearch",function(e){
      var keyword = $("#keyword").val();
      $(".js-appendContxt").empty();
      if (keyword != null && keyword.length != 0) {
        params ='&q='+keyword;
      }else{
        params =''
      }
      // window.location.href="{{ Config::get('app.url') }}/question/create?"+params;
      getAllUrl(params);
    });

  // enter按键搜索
  var j = 0;
    document.onkeydown = function(e) {
        var keyword = $("#keyword").val();
        var params ='q='+keyword;
        var e = event || window.event || arguments.callee.caller.arguments[0],
         keycode = e.which || e.keyCode;
         if (keycode==13) {
            if (keyword != null && keyword.length != 0) {
            j++;
                if(!j==0){
                  var keyword = $("#keyword").val();
                  $(".js-appendContxt").empty();
                  if (keyword != null && keyword.length != 0) {
                    params ='&q='+keyword;
                  }else{
                    params =''
                  }
                  getAllUrl(params);
                }
            } 
            return false; 
         }else{
            return true;
         }
         stopDefault(e);
    }





// --------------------------------------------------------------------------------------------------------------------
// ---------------------------------详情页面---------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
get_lv_reply();
function get_lv_reply(){
    var get_lv_reply_url = jumpUrl+"/question/"+id;
    $.get(get_lv_reply_url,function(){
        
      }, 'json').error(function(data){
            var obj = $.parseJSON(data.responseText);
            $.each(obj.error_messages, function(i, item){
              layer.msg(item[0]);
            });
      }).success(function(data){
        var obj = data.data;
        var comments = obj.comments;
        var str = ''
        for (var i = 0; i < comments.length; i++) {
          str +='<li>'
            str +='<div class="lv-info">'

              str +='<div class="top-icon"></div>'
              str +='<p class="font18 colorF" style="margin:5px 0;">'+comments[i].creator_name+'</p>'
              str +='<p class="font12 colorD">'+comments[i].creator_company_name+'</p>'
              str +='<div class="oh font14" style="margin:10px 8px;">'
                str +='<p class="fl textac colorD"><span class="colorC">'+comments[i].creator_case_count+'</span><br>接单数</p>'
                str +='<p class="fr textac colorD"><span class="colorC">'+comments[i].creator_average_evaluate_score+'</span><br>评分</p>'
              str +='</div>'
              if(comments[i].creator_id){
              str +='<a href="javascript:void(0);" class="font14 butC follow-on" data-id="'+comments[i].creator_id+'">取消关注</a>'
              }else{
             str +='<a href="javascript:void(0);" class="font14 butC follow-off" data-id="'+comments[i].creator_id+'">关注</a>'
              }
            str +='</div>'
            str +='<div class="oh">'
              str +='<div class="fl" style="margin: 10px;">'
                str +='<a href="javascript:void(0);" class="lvimg"><img src="'+comments[i].creator_avatar+'" width="60" height="60" style="border-radius: 50%;"></a>'
              str +='</div>'
              str +='<div class="fr boxr lv-reply-info ">'
                str +='<span class="iconleft"></span>'
                str +='<div class="oh lv-title">'
                  str +='<a href="'+jumpUrl+'/lawyer/'+comments[i].creator_id+'" class="font18 colorA">'+comments[i].creator_name+' </a>'
                  str +='<span class="font14 colorF"> 执业'+comments[i].creator_practice_period+' </span>'
                  str +='<div class="fr operate">'
                    if(comments[i].creator_practice_period){
                    str +='<a href="javascript:void(0);" class="favour-on" data-id="'+comments[i].id+'" title="已赞"><i></i><span class="font14 fl num">512</span></a>'
                    }else{
                    str +='<a href="javascript:void(0);" class="favour-off" data-id="'+comments[i].id+'"  title="点赞"><i></i><span class="font14 fl num">512</span></a>'
                    }
                    str +='<a href="javascript:void(0);" class="reward-on" data-id="'+comments[i].creator_id+'" data-href="'+comments[i].creator_name+'" data-avatar="'+comments[i].creator_avatar+'"><i></i><span class="font14 fl">打赏</span></a>'
                  str +='</div>'
                str +='</div>'
                str +='<div class="content1">'+comments[i].content+'</div>'
                str +='<div class="font14 colorD">'+comments[i].created_at+'</div>'
              str +='</div>'
          str +='</div>'
          str +='</li>'
          };
          $(".lv-reply-list").append(str);
     

      	$(".lvimg").click(function(){
      		$(".lv-info").css("display","none");
      		$(this).parent().parent().siblings(".lv-info").css("display","block");
      	});
        // 头像下面的弹出款
      	$(document).mouseup(function(e){
      	  var region = $('.lvimg,.lv-info');   // 设置目标区域
      	  if(!region.is(e.target) && region.has(e.target).length == 0){
      	  	$(".lv-info").css("display","none");
      	  }
      	});
      	// 发布回答输入款边款变色
      	$(".left-view-box .textarea").focus(function(){  // 获得焦点
      		$(".left-view-box .textarea").css("border","1px solid #48b4ff")
      		$(".left-view-box .iconleft1").addClass("iconleft2").removeClass("iconleft1");
      	}).blur(function(){     // 失去焦点
      		$(".left-view-box .textarea").css("border","1px solid #e8e8e8");
      		$(".left-view-box .iconleft2").addClass("iconleft1").removeClass("iconleft2");
      	});
      	//弹出打赏
      	$(".reward-on").click(function(){
          if(islogin == "" || islogin == null){
            layer.msg("请登录后在打赏！");
            return false;
          }else{
            $(".Popup1 .lv-avatar").attr("src",$(this).attr("data-avatar"));
            $(".Popup1 .lv-realname").text($(this).attr("data-href"));
            var id = $(this).attr("data-id");
        		affirm();
        		$(".layui-layer").css("border-radius","10px")
        		$(".layui-layer-setwin .layui-layer-close2").css({"right":"-40px","top":"0px"});
        		$(".layui-layer-ico").css("background","url("+jumpUrl+"/img/question2/iconlayer.png)");
          }
          // 去打赏
          $(".to-reward").click(function(){
              var loading = layer.msg('', {icon: 16},2000);
              var money = $(".reward-money .money-num").val();
              var to_reward_url = jumpUrl+"/question/public/reward";
              // $.post(to_reward_url,{},function(data){
              // }).error(function(data){
              //    var error =  $.parseJSON(data.responseText);
              // }).success(function(data){
                  // loading.remove();
              //   var obj = data.data;
              //   var loading = layer.msg('打赏订单生成，即将进入支付页面', {icon: 16},2000);
              //   window.location.href = jumpUrl+"/public/reward";
              // });
              layer.msg('打赏订单生成，即将进入支付页面');
              window.location.href = jumpUrl+"/question/public/reward";
          })

      	});
        function affirm(){
          var Popup04 = $(".Popup1");
              layer.open({
                type: 1, //基本层类型  可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）。 若你采用layer.open({type: 1})方式调用，则type为必填项（信息框除外）
                title: false, //标题
                closeBtn: true,  //关闭按钮
                shade:0.3,  //遮罩默认是0.3透明度
                area: ['355px', '413px'],
                skin: 'yourclass', //样式类名
                content: Popup04 //内容 
            });
        };
        
        $(".reward-money i").click(function(){
          var math_num = Math.round(Math.random()*8)+1;
          $(".money-num").text(math_num);

          });
          //点赞
          $(document).on('click', '.favour-off', function(e) {
            if(islogin == "" || islogin == null){
              layer.msg("请登陆后在点赞！"); 
            }else{
              
              var item_id = $(this).attr("data-id");
              var token = $("input:[name='_token']").val();
              var params = {};
              var $this = $(this);
              params['item_type'] = 'comment';
              params['item_id'] = item_id;
              params['_token'] = token;
              // console.info(params)
              var url = jumpUrl+'/like';
              $.post(url,params,function(data){
                }, "json").error(function(data) {
                  var error =  $.parseJSON(data.responseText);
                  // layer.msg(error.error_messages.item_type[0]);
                }).success(function(data) {
                  $this.children(".num").text(data.data['likes_count']);
                  $(".favour-off").addClass("favour-on").removeClass("favour-off");
                  $(".favour-off").attr("title","已赞");
                  layer.msg('点赞成功');
                });
            }
            
            stopDefault(e);
          });
          //取消点赞
          $(document).on('click', '.favour-on', function(e) {
            if(islogin == "" || islogin == null){
              layer.msg("请登陆后在点赞！"); 
            }else{
              var item_id = $(this).attr("data-id");
              var token = $("input:[name='_token']").val();
              var params = {};
              var $this = $(this);
              params['item_type'] = 'comment';
              params['item_id'] = item_id;
              params['_token'] = token;
              // console.info(params)
              var url = jumpUrl+'/like/remove';
              $.post(url,params,function(data){
                }, "json").error(function(data) {
                  var error =  $.parseJSON(data.responseText);
                  // layer.msg(error.error_messages.item_type[0]);
                }).success(function(data) {
                  $this.children(".num").text(data.data['likes_count']);
                  $(".favour-on").addClass("favour-off").removeClass("favour-on");
                  layer.msg('取消成功');
                });
            }
            stopDefault(e);
          });



          //收藏

          $(document).on("click", ".collect-off", function(e){
            if(islogin == "" || islogin == null){
            layer.msg("请登录后在收藏！");
            return false;
          }else{
            var loading = layer.msg('操作进行中...', {icon: 16});
            var $this = $(this);
            var url = jumpUrl+"/collect";
            var thisId = $this.attr("data-id");
            var _token = $("input[name='_token']").val();
            $.post(url,{'collect_type':'1', 'item_id':thisId, '_token':_token},function(){
              
            }, 'json').error(function(data){
                  var obj = $.parseJSON(data.responseText);
                  $.each(obj.error_messages, function(i, item){
                    layer.msg(item[0]);
                  });
            }).success(function(data){
              var obj = data.data;
                layer.msg('收藏成功');
                $(".collect-off").addClass("collect-on").removeClass("collect-off");
                $this.children('.shu').text(obj);
            });
            }
          });

          //取消收藏
          $(document).on("click", ".collect-on", function(e){
            layer.mas("您已经点过赞了")
          //   if(islogin == "" || islogin == null){
          //   layer.msg("请登录后在收藏！");
          //   return false;
          // }else{
          //   var loading = layer.msg('操作进行中...', {icon: 16});
          //   var $this = $(this);
          //   var url = jumpUrl+"/collect/delete";
          //   var thisId = $this.attr("data-id");
          //   var _token = $("input[name='_token']").val();
          //   $.post(url,{'collect_type':'1', 'item_id':thisId, '_token':_token},function(){
              
          //   }, 'json').error(function(data){
          //         var obj = $.parseJSON(data.responseText);
          //         $.each(obj.error_messages, function(i, item){
          //           layer.msg(item[0]);
          //         });
          //   }).success(function(data){
          //     var obj = data.data;
          //       layer.msg('取消收藏成功');
          //       $(".collect-on").addClass("collect-off").removeClass("collect-on");
          //   });
          //   }
          });

          //点击关注
        $(document).on('click', '.follow-off', function(e) {
          
          if(islogin == "" || islogin == null){
            layer.msg("请登录后在关注！");
            return false;
          }else{
            var loading = layer.msg('操作进行中...', {icon: 16});
            var $this = $(this);
            var follow_id = $(this).attr("data-id");
            var params = {};
            params['follow_id'] = follow_id;
            params['user_id'] = user_id;
            var url = jumpUrl+'/follow';
            $.post(url,params,function(data){
              }, "json").error(function(data) {
                var error =  $.parseJSON(data.responseText);
                $.each(error.error_messages, function(i, item){
                  layer.msg(item[0]);
                });

              }).success(function(data) {
                var obj = data.data;
                layer.msg(obj);
                $this.text("取消关注");
                $this.addClass("follow-on").removeClass("follow-off");
                })
            }
            stopDefault(e);
          });
         //取消关注
        $(document).on('click', '.follow-on', function(e) {
          if(islogin == "" || islogin == null){
            layer.msg("请登录后在关注！");
            return false;
          }else{
            var loading = layer.msg('操作进行中...', {icon: 16});
            var $this = $(this);
            var follow_id = $(this).attr("data-id");
            var params = {};
            params['follow_id'] = follow_id;
            params['user_id'] = user_id;
            var url = jumpUrl+'/follow/remove';
            $.post(url,params,function(data){
              }, "json").error(function(data) {
                var error =  $.parseJSON(data.responseText);
                $.each(error.error_messages, function(i, item){
                  layer.msg(item[0]);
                });

              }).success(function(data) {
                var obj = data.data;
                layer.msg(obj);
                $this.text("关  注");
                $this.addClass("follow-off").removeClass("follow-on");
                })
            }
            stopDefault(e);
          });


        // 发布回答
        $(".Release-response").click(function(){
          if(islogin == "" || islogin == null){
            layer.msg("请登录后再回答！");
            return false;
          }else if(login_isLawyer_id == "" || login_isLawyer_id == null){
            layer.msg("只有律师才能回答");
            return false;
          }else{
            var comment = $(".textarea").val();
            if (comment<1) {
              layer.msg("回答内容不能为空");
              return false;
            }else{
              var loading = layer.msg('操作进行中...', {icon: 16});
              var response_url = jumpUrl+"/question/"+id+"/comment";
              $.post(response_url,{"comment":comment,"creator_id":user_id},function(data){
                },"json").error(function(data){
                  var error =  $.parseJSON(data.responseText);
                  $.each(error.error_messages, function(i, item){
                    layer.msg(item[0]);
                  });
                }).success(function(data){
                  loading.remove();
                   var obj = data.data;
                   layer.msg("回答成功");
              });
            }
          }

        });

  });

}
// -------------------------------------------------------------------------------------------------------------------------
//--------------------发布问题----------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------------


	$(".quesTitle").focus(function(){  // 获得焦点
		$(".quesTitle").css("border","1px solid #48b4ff")
	}).blur(function(){     // 失去焦点
		$(".quesTitle").css("border","1px solid #e8e8e8");
	});
	$(".itxtarea").focus(function(){  // 获得焦点
		$(".itxtarea").css("border","1px solid #48b4ff")
	}).blur(function(){     // 失去焦点
		$(".itxtarea").css("border","1px solid #e8e8e8");
	});

	//获取擅长领域的数据
    $.get(jumpUrl+'/lawyer/workscopes', function(data){
          
        }, "json").error(function(data) {
          var status_code = $.parseJSON(data.responseText);
          layer.msg(status_code.message);
        }).success(function(data) {
           var obj = data.data;
            var work_scope = obj;
            var src = '';
            $.each(work_scope, function(key, item) {
            	src+='<a value="'+item.key+'">'+item.value+'</a>';
            });
            $(".commit-type2 .type-list").append(src);


            $(".type-list a").click(function(){
		    	var text = $(this).text();
		    	var value = $(this).attr("value")
		    	$(".commit-type1 .commit-title").text(text);
		    	$(".commit-type1 .commit-title").attr("value",value);
		    	$(".commit-type2 .commit-title").text(text);
		    	$(".commit-type2 .commit-title").attr("value",value);
		    	$(".commit-type2 .type-list a").removeClass("selected");
		    	$(this).addClass("selected");
		    });
    });
    
    $(".commit-type1").click(function(){
    	// $(".commit-type1").css("display","none");
		$(".commit-type2").css("display","block");
	});
	$(".commit-type2").click(function(){
    	$(".commit-type2").css("display","none");
		// $(".commit-type1").css("display","block");
	});
	$(".Error-closing").click(function(){
		$(".Error-prompt").css("display","none");
	});

	//提交咨询
  $(document).on( "click", ".subAdvisory", function(e) { 
      if(islogin == "1"){
        if (login_isLawyer_id == "1") {
          layer.msg("律师用户不能发布问题!");
            return false;
        };
            
      }
      var title = $.trim($("#title").val());
      var content = $.trim($("#content").val());
      var work_scope = $.trim($(".commit-type1 .commit-title").attr("value"));
      var WeiXinImg = '<div class="weixincode"><br><br>'
            WeiXinImg+='<p>提交成功！感谢您的咨询，律团网的律师会尽快为您解答！</p><br>'
            WeiXinImg+='<p class="WeiXinImg"></p>'
            WeiXinImg+='<br><p><p>扫一扫<span style="color:#ff446f">关注服务号，随时随地收到回复</span></p>'
          WeiXinImg+='</div>'
      if(work_scope.length < 1){
      		$(".Error-prompt").css("display","block");
      		$(".textcon").text("请选择案件类型！")
          return false;
      }else if(title.length<2||title.length>30){
      		$(".Error-prompt").css("display","block");
      		$(".textcon").text("标题不能小于2个字或者大于30个字！")
          return false;
      }else if(content.length < 1){
      		$(".Error-prompt").css("display","block");
      		$(".textcon").text("内容不能为空！")
          return false;
      }else if(content.length < 10||content.length > 300){
      		$(".Error-prompt").css("display","block");
      		$(".textcon").text("标题不能小于10个字或者大于300个字！")
          return false;
      }else{
          var loading = layer.msg('加载中...', {icon: 16});
          var inquery = $("#inquery_create_form");
          $(this).attr("disabled","disabled");
          $.post(attrUrl+"/center/question/insert/question",{"title":title,"content":content,"cat_id":work_scope},
             function(data){
                $(':input',inquery).not(':button, :submit, :reset, :hidden').val(''); 
                $(".error-prompt").css("display","none");
                $(".commit-type1 .commit-title").attr("value","").text("选择咨询类别");
                var post_id = data.data.post_id;
                var layerWeiXinCode = '<div class="weixincode">'
                  layerWeiXinCode+='<h3 class="distance">提交成功！感谢您的咨询，律团网的律师会尽快为您解答！</h3>'
                    layerWeiXinCode+='<h3 class="distance">亲，要注册或者登录以后才能看到律师对您的回答哦。</h3>'
                    layerWeiXinCode+='<a href="'+register+'?post_id='+post_id+'" class="jiushizhege"><span style="color:#FFF">去注册</span></a>'
                    layerWeiXinCode+='<a href="'+login+'?post_id='+post_id+'" class="jiushizhege"><span style="color:#FFF">去登陆</span></a>'
                  layerWeiXinCode+='</div>';
                if(islogin == "" || islogin == null){
                    var weixincode = layer.open({
                          type: 1, //基本层类型  可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）。 若你采用layer.open({type: 1})方式调用，则type为必填项（信息框除外）
                          title: false, //标题
                          closeBtn: true,  //关闭按钮
                          shade:0.3,  //遮罩默认是0.3透明度
                          shadeClose: false,  //是否点击遮罩关闭
                          area: ['450px', '400px'],
                          skin: 'yourclass', //样式类名
                          content: layerWeiXinCode //内容
                    });
                }else{
                    // layer.msg("提交成功！感谢您的咨询，律团网的律师会尽快为您解答！");
                    var weixincode = layer.open({
                          type: 1, //基本层类型  可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）。 若你采用layer.open({type: 1})方式调用，则type为必填项（信息框除外）
                          title: false, //标题
                          closeBtn: true,  //关闭按钮
                          shade:0.3,  //遮罩默认是0.3透明度
                          shadeClose: false,  //是否点击遮罩关闭
                          area: ['450px', '360px'],
                          skin: 'yourclass', //样式类名
                          content: WeiXinImg //内容
                    });
                    $(".filename ul li").remove();
                    $("input:hidden[name='file_paths[]']").remove();
                    $("input:hidden[name='file_names[]']").remove();
                }
                layer.close(loading); 
                 $(".subAdvisory").removeAttr('disabled');
             }, "json").error(function(data) {
               var obj = $.parseJSON(data.responseText);
               layer.msg(obj.message);
             }).success(function(data){
              var obj = data.data;
             });
             
             return true;
      }
      stopDefault(e);
  });


// --------------------------------------------------------------------------------------------------------------------
// -------------------------------付款界面-----------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------

  $(".order-pay .checkboxIcon").click(function(){
    $(".checkboxIcon").removeClass("checkedIcon");
    $(this).addClass("checkedIcon");
  });
  $(".submit-but").click(function(){
    var pay_type = $(".checkedIcon").attr("data-href");
    var money_num = $(".moneyNum").val();
    
    if (pay_type == "weixin") {        // 微信支付
      layer.msg("微信支付未完成");
      return false;
    }else if (pay_type == "alipay") {    // 支付宝支付
      layer.msg("支付宝支付未完成");
      return false;

    }else if(pay_type == "wallet") {   // 钱包支付
      layer.msg("钱包支付未完成");
        var pay_url = jumpUrl+"/center/question/486/pay/wallet";
        $.post(pay_url,function(data){
          },'json').error(function(data) {
              var obj = $.parseJSON(data.responseText);
              layer.msg(obj.error_messages);
          }).success(function(data) {
              layer.msg(data.data);
              window.location.href=jumpUrl+"/question/public/list";
          });
      return false;
    }else{
      layer.msg("请选择付款类型");
      return false;
    }


  });


})
